<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ page isELIgnored="false" %>
<%
String path = request.getContextPath();
%>
<script language="JavaScript" src="<%=path %>/js/public.js" type="text/javascript"></script>

  <form action="<%=path %>/user?type=userLogin" name="ThisForm" method="post">
    
    <h2>个人中心</h2>
<c:if test="${sessionScope.userType==null}">
<script type='text/javascript' src='<%=path %>/dwr/interface/loginService.js'></script>
<script type='text/javascript' src='<%=path %>/dwr/engine.js'></script>
<script type='text/javascript' src='<%=path %>/dwr/util.js'></script>
<script type="text/javascript">
	        function reg()
	        {
	                var url="<%=path %>/qiantai/userinfo/userReg.jsp";
	                window.location.href=url;
	        }
	        
	        function check()
			{                                                                                         
			     if(document.ThisForm.userName.value=="")
				 {
				 	alert("请输入用户名");
					return false;
				 }
				 if(document.ThisForm.userPw.value=="")
				 {
				 	alert("请输入密码");
					return false;
				 }
				 document.getElementById("indicator").style.display="block";
				 loginService.login(document.ThisForm.userName.value,document.ThisForm.userPw.value,document.ThisForm.userType.value,callback);
			}
		
			function callback(data)
			{
			    document.getElementById("indicator").style.display="none";
			    if(data=="no")
			    {
			        alert("用户名或密码错误");
			    }
			    if(data=="yes")
			    {   alert("登陆成功");
			        window.location.reload();
			    }
			    
			}
	</script>
    <table cellspacing="0" cellpadding="0" width="98%" align="center" border="0">
      <tr>
        <td align="right" width="31%" height="30" >用户名：</td>
        <td align="left" width="69%"><input  title="用户名不能为空" size="30" name="userName" type="text" /></td>
      </tr>
      <tr>
        <td align="right" height="30"  >密　码：</td>
        <td align="left"><input  title="密码不能为空" type="password" size="30" name="userPw"/></td>
      </tr>
      <tr>
        <td align="center" ></td>
        <td align="center"  >
                           <input name="userType" style="width: 70px" type="hidden" value="2">
        
        <input type="button" value="登  录" onclick="check()" class="button"/>
        <input type="button" value="注  册" onclick="reg()"  class="button" />
          <img id="indicator" src="<%=path %>/images/loading.gif" style="display:none"/></td>
      </tr>
    </table>
</c:if>
<c:if test="${sessionScope.userType!=null && sessionScope.userType==2}"> 
   &nbsp;&nbsp;&nbsp;&nbsp;欢迎您：${sessionScope.stu.name1 } (学生用户)
   <ul>
 <!--<li> <a href="<%=path %>/liuyan?type=liuyan_mime">留言管理</a> </li>  --> 
  <li> <a href="<%=path %>/stu?type=stuEdit">信息修改</a> </li>
  <li> <a href="<%=path %>/chengji?type=chengjiAll">成绩管理</a> </li>
  <li> <a href="<%=path %>/timu?type=timu_stu">我的题目</a> </li>
   <li> <a href="<%=path %>/stu?type=logout">安全退出</a>  </li>
  </ul>
</c:if>
<c:if test="${sessionScope.userType!=null && sessionScope.userType==1}"> 
   &nbsp;&nbsp;&nbsp;&nbsp;欢迎您：${sessionScope.stu.name1 } (教师用户)
   <ul>
 <!--<li> <a href="<%=path %>/liuyan?type=liuyan_mime">留言管理</a> </li>  --> 
  <li> <a href="<%=path %>/stu?type=stuEdit">信息修改</a> </li>
  <li>           <a href='<%=path %>/chengji?type=chengjiTeaMana'>成绩管理</a>    </li>
  <li>           <a href='<%=path %>/kecheng?type=kechengTeaMana'>课程管理</a>    </li>
  <li>        <a href='<%=path %>/zhangjie?type=zhangjieMana'>章节管理</a>    </li>
    <li>        <a href='<%=path %>/timu?type=timuMana1'>单选题管理</a>     </li>
   <li>        <a href='<%=path %>/timu?type=timuMana2'>多选题管理</a>   </li>
   <li>         <a href='<%=path %>/timu?type=timuMana3'>判断题管理</a>    </li>
           
   <li> <a href="<%=path %>/stu?type=logout">安全退出</a>  </li>
  </ul>
</c:if>
  </form>
